Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow starting a span on a transaction that has already ended #2653

Merged
merged 2 commits into from
Apr 21, 2022

Conversation

trentm
Copy link
Member

@trentm trentm commented Apr 20, 2022

This was a restriction that dated back to the v1 APM Server intake
API that required all a transaction's spans to be sent along with the
transaction.

The Java APM agent, FWIW, allows this.

This came up in discussion about some edge cases with the OTel Bridge. As we move closer to OTel semantics, the distinction between transactions and spans gets to be less. Currently can start a child span of a span that has already ended, so it is nice to be able to do the same for a transaction.

Checklist

  • Implement code
  • Add tests
  • Add CHANGELOG.asciidoc entry

This was a restriction that dated back to the v1 APM Server intake
API that required all a transaction's spans to be sent along with the
transaction.

The Java APM agent, FWIW, allows this.
@trentm trentm self-assigned this Apr 20, 2022
@github-actions github-actions bot added the agent-nodejs Make available for APM Agents project planning. label Apr 20, 2022
@apmmachine
Copy link
Contributor

apmmachine commented Apr 20, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-04-21T18:47:10.399+0000

  • Duration: 21 min 55 sec

Test stats 🧪

Test Results
Failed 0
Passed 247149
Skipped 0
Total 247149

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • run module tests for <modules> : Run TAV tests for one or more modules, where <modules> can be either a comma separated list of modules (e.g. memcached,redis) or the string literal ALL to test all modules

  • run benchmark tests : Run the benchmark test only.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@trentm trentm requested a review from astorm April 20, 2022 19:26
@trentm
Copy link
Member Author

trentm commented Apr 20, 2022

Here is an example of a trace (in APM UI v7.15.0) that shows a span ("s6") that started after its transaction ended:

Screen Shot 2022-04-20 at 12 33 41 PM

This is from running script https://github.com/elastic/apm-agent-nodejs/blob/trentm/otel-bridge/test/opentelemetry-sdk/fixtures/start-span-with-context.js from the ongoing OTel Bridge work.

trentm added a commit that referenced this pull request Apr 20, 2022
This takes the coming changes from #2653 so that tests pass with
this restriction lifted.
Copy link
Contributor

@astorm astorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable -- especially if java does it. Also, the implementation is reasonable.

Just to say it out loud (not a blocker) I am slightly curious what, if any, effect this will have on features that rely on the transaction's span_count -- it seems like it's possible for these late spans to not be counted (depending on whether an ended transaction's been reported).

A question for future us, I suppose :). Approving, presuming the current CI failures as a :jenkins: hiccup.

@trentm
Copy link
Member Author

trentm commented Apr 21, 2022

it seems like it's possible for these late spans to not be counted

Thanks for mentioning it. Yes. We'd discussed this in chat briefly. Felix's opinion was:

[Trent]

Do you think that transaction.span_count.* values being possibly less than the number of span documents will surprise/break any APM UI code?

[Felix]

The Java agent already supports spans that end after their transaction. I don’t think it will break the UI. It shows a warning if it can find fewer spans than expected but not if it finds more than expected.

@trentm
Copy link
Member Author

trentm commented Apr 21, 2022

/test

@trentm trentm merged commit 9bdbd07 into main Apr 21, 2022
@trentm trentm deleted the trentm/allow-start-span-on-ended-trans branch April 21, 2022 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-nodejs Make available for APM Agents project planning.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants